#!/bin/bash

# 设置变量
LIBEXIF_VERSION="0.6.24"
LIBEXIF_TAR="libexif-${LIBEXIF_VERSION}.tar.bz2"
LIBEXIF_URL="http://libexif.sourceforge.net/archives/${LIBEXIF_TAR}"
INSTALL_PREFIX="/home/luke/project/tools/install/exif/"  # 修改为您的安装路径
CROSS_COMPILE="aarch64-linux-musleabi"  # 修改为您的交叉编译前缀，例如 arm-linux-gnueabi-

# 下载源代码
if [ ! -f "${LIBEXIF_TAR}" ]; then
    echo "Downloading ${LIBEXIF_TAR}..."
    wget "${LIBEXIF_URL}"
fi

# 解压源代码
if [ ! -d "libexif-${LIBEXIF_VERSION}" ]; then
    echo "Extracting ${LIBEXIF_TAR}..."
    tar -xjf "${LIBEXIF_TAR}"
fi

# 进入源代码目录
cd "libexif-${LIBEXIF_VERSION}" || exit

# 配置编译选项
echo "Configuring libexif for cross-compilation..."
./configure --host=${CROSS_COMPILE} --prefix=${INSTALL_PREFIX}

# 编译
echo "Building libexif..."
make

# 安装
echo "Installing libexif..."
make install

# 清理
cd ..
rm -rf "libexif-${LIBEXIF_VERSION}"
echo "Cleaning up..."

echo "libexif-${LIBEXIF_VERSION} has been cross-compiled and installed successfully."
